package com.buka.role.controller;

import com.buka.common.ResultJson;
import com.buka.role.service.RoleService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/role/del")
public class DeleteServlet extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String id = req.getParameter("id");
        RoleService roleService = new RoleService();
        int delete = roleService.delete(Long.parseLong(id));

        if(delete > 0){
            resp.getWriter().write(ResultJson.success());
        }else{
            resp.getWriter().write(ResultJson.error());
        }
    }
}
